package org.example.struct.array;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/1/4 10:14
 * @apiNote
 */

public class Test00728SelfDividingNumbers {
    public static void main(String[] args) {
        selfDividingNumbers(1,22);
    }

    public static List<Integer> selfDividingNumbers(int left, int right) {
        List<Integer> res = new ArrayList<>();
        for(int i = left; i <= right; i++){
            if(checkNum(i)){
                res.add(i);
            }
        }
        return res;
    }

    public static boolean checkNum(int num) {
        boolean flag = true;
        int dig = num;
        while(dig > 0){
            int temp = dig % 10;
            dig /=10;
            if(temp == 0 || num % temp != 0){
                return false;
            }
        }
        return flag;
    }
}
